<?php $title = '首页'; require './header.php'; ?>

<div class="container-fluid">
	<!-- 首推列表 -->
	<?php $posts = $hlx->getSlideList(); ?>
	<div id="slide" class="carousel slide" data-ride="carousel">
		<ul class="carousel-indicators">
			<?php foreach($posts as $key => $post) { ?>
			<li data-target="#slide" data-slide-to="<?php echo $key; ?>" class="<?php echo $key == 0 ? 'active' : ''; ?>"></li>
			<?php }?>
		</ul>
		<div class="carousel-inner">
			<?php foreach($posts as $key => $post) { ?>
			<div class="carousel-item <?php echo $key == 0 ? 'active' : ''; ?>" onclick="javascript:location.href='./post.php?post_id=<?php echo $post['jumpMode']; ?>';">
				<img src="<?php echo $post['coverUrl']; ?>" width="100%">
				<div class="carousel-caption">
					<h3><?php echo $post['title']; ?></h3>
				</div>
			</div>
			<?php } ?>
		</div>
		<a class="carousel-control-prev" href="#slide" data-slide="prev">
			<span class="carousel-control-prev-icon"></span>
		</a>
		<a class="carousel-control-next" href="#slide" data-slide="next">
			<span class="carousel-control-next-icon"></span>
		</a>
	</div>
	<br>
	<!-- 首推列表 -->
	
	<!-- 版块列表 -->
	<table class="table table-bordered">
		<tr>
		<?php
		$cats = $hlx->getCategoryList();
		$i = 0;
		foreach($cats as $cat) {
			if($cat['type'] != 1) {
				$i ++;
		?>
			<td onclick="javascript:location.href='./category.php?cat_id=<?php echo $cat['categoryID']; ?>';">
				<div class="media">
					<img src="<?php echo $cat['icon']; ?>" alt="版块ID" class="mr-3 rounded" style="width:60px;">
					<div class="media-body">
						<h4><?php echo $cat['title']; ?></h4>
						<p><?php echo $cat['description'] ?: '这个版块没有描述'; ?></p>
					</div>
				</div>
			</td>
		<?php
				if($i % 2 == 0) {
					echo '</tr><tr>';
				}
			}
		}
		?>
		</tr>
	</table>
	<!-- 版块列表 -->
</div>
</body>
</html>